<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS 垂直居中</title>

  <style>
    html, body {
      padding: 0;
      margin: 0;
    }

    .parent {
      width: 500px;
      height: 600px;
      border: 1px solid #eee;
      background: rgb(124, 124, 219);
      /* 转换为表格单元格显示，类似 <td> 和 <th> */
      display: table-cell;  
      vertical-align: middle;
      text-align: center;
    }

    .child {
      width: 300px;
      height: 200px;
      background-color: pink;
      display: inline-block;
    }
  </style>
</head>
<body>
  <div class="parent">
    <div class="child"></div>
  </div>
</body>
</html>